import { Component, OnInit } from '@angular/core';
import { StorageService } from '../../service/storage.service';
import { CommonService } from '../../service/common.service';

@Component({
  selector: 'app-rechargerecord',
  templateUrl: './rechargerecord.page.html',
  styleUrls: ['./rechargerecord.page.scss'],
})
export class RechargerecordPage implements OnInit {

  public list: any[] = [];
  public page = 1;
  public limit = 10;
  public flag = false;

  constructor(private storage: StorageService,private common: CommonService) { }

  ngOnInit() {
    this.PayDetail();
  }

  // 获取充值明细
  PayDetail(){
    const api = '/tbr/queryOfflinePayDetail';
    const params = {
      userId:this.storage.get('PersonalInfo').userId,
      page:this.page,
      limit:this.limit
    };
    this.common.post(api,params,false).then((res: any)=>{
      console.log(res);
      if(res.code == 200){
        if(res.code == 200){
          for(let i=0;i<res.data.records.length;i++){
            this.list.push(res.data.records[i]);
          }
          if(res.data.records.length < this.limit){
            this.flag = true;
          }
        }
      }
    });
  }

  loadData(event){
    if (this.flag == true) {
      event.target.disabled = true;
      return;
    }
  setTimeout(()=>{
    this.page += 1;
    this.PayDetail();
    event.target.complete();
  },700);
}

}
